<?php

class t_search extends CodeIgniterUnitTestCase {

     private $data;
     private $service_url = 'http://localhost/services-hotels/ibookhotelrest/hotel/';
     private $specific_dates = FALSE;
     private $post = array();

     public function __construct() {

          parent::__construct('Test Home Page');

          $this->load->library('rest', array(
              'server' => $this->service_url
          ));
     }

     public function setUp() {
          $this->post = array(
              'destination_hotel' => "b",
              'check_in' => "21.12.2012",
              'check_out' => "22.12.2012",
              'nr_adults' => "2",
              'nr_childrens' => "0",
              'ages' => array(),
          );
     }

     public function tearDown() {
          
     }

     public function test_search() {

          // create session from GET params
          $params = $this->get_post_array("post");

          if ($this->specific_dates) {

               //$this->popular($params['dest_hot'], NULL);
          } else {

               $this->data['objects'] = $this->rest->post('search', $params);
               $this->dump($params);
          }

          $this->dump($this->data);
     }

     public function get_post_array($post_type) {

          switch ($post_type) {

               case "session":
                    $data = array(
                        'check_in' => "27.11.2012",
                        'check_out' => "28.11.2012",
                        'nr_adults' => 3,
                        'nr_childrens' => 0
                    );
                    break;

               case "post":
                    $data = array(
                        'dest_hot' => $this->post['destination_hotel'],
                        'check_in' => $this->post['check_in'],
                        'check_out' => $this->post['check_out'],
                        'nr_adults' => $this->post['nr_adults'],
                        'nr_childrens' => $this->post['nr_childrens'],
                        'ages' => $this->post['ages'],
                        'page_type' => "SEACRH"
                    );

                    if ($this->specific_dates) {
                         $data['specific_dates'] = TRUE;
                    } else {
                         $data['specific_dates'] = NULL;
                    }

                    break;
          }

          return $data;
     }

}

?>